package com.kscrm.web.controller.web;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.kscrm.common.annotation.Log;
import com.kscrm.common.core.controller.BaseController;
import com.kscrm.common.core.domain.AjaxResult;
import com.kscrm.common.enums.BusinessType;
import com.kscrm.web.domain.ProjectCollection;
import com.kscrm.web.service.IProjectCollectionService;
import com.kscrm.common.core.page.TableDataInfo;

/**
 * 项目收款Controller
 * 
 * @author Dhq
 * @date 2025-04-08
 */
@RestController
@RequestMapping("/web/collection")
public class ProjectCollectionController extends BaseController
{
    @Autowired
    private IProjectCollectionService projectCollectionService;

    /**
     * 查询项目收款列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ProjectCollection projectCollection)
    {
        startPage();
        List<ProjectCollection> list = projectCollectionService.selectProjectCollectionList(projectCollection);
        return getDataTable(list);
    }

    /**
     * 获取项目收款详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(projectCollectionService.selectProjectCollectionById(id));
    }

    /**
     * 新增项目收款
     */
    @Log(title = "项目收款", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectCollection projectCollection)
    {
        return toAjax(projectCollectionService.insertProjectCollection(projectCollection));
    }

    /**
     * 修改项目收款
     */
    @Log(title = "项目收款", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectCollection projectCollection)
    {
        return toAjax(projectCollectionService.updateProjectCollection(projectCollection));
    }

    /**
     * 删除项目收款
     */
    @Log(title = "项目收款", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectCollectionService.deleteProjectCollectionByIds(ids));
    }
}
